import React, { Component } from 'react'
import Child from './Child'

export default class App extends Component {
  state = {
    count: 99,
    msg: '1',
  }

  // 1. 父组件定义一个操作数据的方法
  updateMsg = (msg) => {
    console.log(222222)
    this.setState({
      msg,
    })
  }
  render() {
    return (
      <div>
        <h3>父组件-{this.state.msg}</h3>
        <p>{this.state.count}</p>
        <hr />
        <Child
          msg={this.state.msg}
          count={this.state.count}
          updateMsg={this.updateMsg}
        ></Child>
      </div>
    )
  }
}
